package com.learn.spring.service;

import com.learn.spring.dao.ITransactionDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
//@Transactional(propagation = Propagation.REQUIRED)
public class TransactionService {

    @Autowired
    private ITransactionDao transactionDao;

    public void accountMoney() {
        transactionDao.outMoney(135, 10);
        int i = 10 / 0;
        transactionDao.inMoney(134, 10);
    }

    @Transactional
    public void accountMoneyTransaction() {
        transactionDao.inMoney(135, 10);
        int i = 10 / 0;
        transactionDao.outMoney(134, 10);
    }

    public void accountMoneyTransactionXml() {
        transactionDao.inMoney(135, 10);
        int i = 10 / 0;
        transactionDao.outMoney(134, 10);
    }


}
